package usedForPage;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Reader {

	public static List<NickNames> getLstNickNames() {
		List<NickNames> lstNick = new ArrayList<NickNames>();
		try {
			String pathFile = "nickNames.csv", line;
			BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(pathFile), "UTF-8"));
			String[] ar;
			while ((line = bf.readLine()) != null) {
				NickNames nick = new NickNames();
				ar = line.split(",");
				if (ar.length == 3) {
					nick.setNickname(ar[0].toLowerCase());
					nick.setRealName(ar[1].toLowerCase());
					nick.setProb(Double.parseDouble(ar[2]));
				} else {
					System.out.println(line);
				}
				lstNick.add(nick);
			}
			bf.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lstNick;
	}

	
	public static List<String> getProviderNames(String path) {
		List<String> lstProvider = new ArrayList<String>();
		try {
			String line, name;
			String[] temp;
			BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
			line = bf.readLine();//
			while ((line = bf.readLine()) != null) {
				temp = line.split(",");
				name = temp[1].trim();
				lstProvider.add(name);
			}
			bf.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lstProvider;
	}

}
